package com.TeamJigsaw.DanteTrail.Models;
import java.util.Random;

import com.TeamJigsaw.DanteTrail.Models.RandomEvent;
/**
 * Represents an even that affects the party's wagon
 * @author Vince
 *
 */
public class WagonEvent extends RandomEvent{

	private String eventMessage;

	private Random generator;

	public  WagonEvent(){
		this.eventMessage = null;
		generator = new Random();
	}
	@Override
	public boolean performEvent(Party party){
		int newRand = generator.nextInt(101);

		
		if (party.getPlayer().getProfession().getSpecialSkill() != 2){
			if (newRand > 100){
				newRand = generator.nextInt(101);
				if (newRand < 34){ //Wheel is broken
					eventMessage = "A wheel has broken! You need another wheel to fix it.";
					party.addWheels(-1);
				}
				else if (newRand < 67){ //Axel is broken
					eventMessage = "A axel has broken! You need another axel to fix it.";
					party.addAxels(-1);
				}
				else if (newRand < 100){
					eventMessage = "A Tongue has broken! You need another tongue to fix it!";
					party.addTongues(-1);
				}
				return true;
			}
		}
		else {
			if (newRand > 110){
				newRand = generator.nextInt(101);
				if (newRand < 34){ //Wheel is broken
					eventMessage = "A wheel has broken! You need another wheel to fix it.";
					party.addWheels(-1);
				}
				else if (newRand < 67){ //Axel is broken
					eventMessage = "A axel has broken! You need another axel to fix it.";
					party.addAxels(-1);
				}
				else if (newRand < 100){
					eventMessage = "A Tongue has broken! You need another tongue to fix it!";
					party.addTongues(-1);
				}
				return true;
			}
		}

		return false;
	}
	
	@Override
	public String getMessage(){
		return eventMessage;
	}

	/**
	 * Returns a string representation of the class
	 * @return A string representation of the class
	 */
	@Override
	public String toString() {
		return ("This is a wagon event class");
	}
}